//package com.whfp.coky.ui.task.act
//
//import android.app.Activity
//import android.content.Context
//import android.content.Intent
//import android.os.Bundle
//import androidx.core.content.ContextCompat
//import androidx.recyclerview.widget.GridLayoutManager
//import com.whfp.coky.CopyFrag
//import com.whfp.coky.R
//import com.whfp.coky.databinding.ActivityFluorMainBinding
//import com.whfp.coky.ui.adpter.FragmentPagerAdapter
//import com.whfp.coky.ui.adpter.NavigationAdapter
//import com.whfp.coky.ui.base.BaseActivity
//import com.whfp.coky.ui.base.BaseFragment
//import com.whfp.coky.ui.task.vm.fluor.FluorMainVM
//
///**
//*
//* 荧光检测
//* author coky
//* created 2022/3/16 15:34
//*/
//
//class FluorMainActSave : BaseActivity<FluorMainVM,ActivityFluorMainBinding>(),
//    NavigationAdapter.OnNavigationListener{
//
//    companion object {
//        private const val INTENT_KEY_IN_FRAGMENT_INDEX: String = "fragmentIndex"
//        private const val INTENT_KEY_IN_FRAGMENT_CLASS: String = "fragmentClass"
//
//        @JvmOverloads
//        fun start(context: Context, fragmentClass: Class<out BaseFragment<*,*>?>? = CopyFrag::class.java) {
//            val intent = Intent(context, FluorMainActSave::class.java)
//            intent.putExtra(INTENT_KEY_IN_FRAGMENT_CLASS, fragmentClass)
//            if (context !is Activity) {
//                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
//            }
//            context.startActivity(intent)
//        }
//    }
//
//    private var navigationAdapter: NavigationAdapter? = null
//    private var pagerAdapter: FragmentPagerAdapter<BaseFragment<*,*>>? = null
//
//    override fun initView() {
//        navigationAdapter =NavigationAdapter(getContext()).apply {
//            addItem(NavigationAdapter.MenuItem(getString(R.string.main_fluor_01),
//                ContextCompat.getDrawable(this@FluorMainActSave, R.drawable.fluor_01_selector)))
//            addItem(NavigationAdapter.MenuItem(getString(R.string.main_fluor_02),
//                ContextCompat.getDrawable(this@FluorMainActSave, R.drawable.fluor_02_selector)))
//            addItem(NavigationAdapter.MenuItem(getString(R.string.main_fluor_03),
//                ContextCompat.getDrawable(this@FluorMainActSave, R.drawable.fluor_03_selector)))
//            addItem(NavigationAdapter.MenuItem(getString(R.string.main_fluor_04),
//                ContextCompat.getDrawable(this@FluorMainActSave, R.drawable.fluor_04_selector)))
//            listener = this@FluorMainActSave
//            this.itemClick {
//                pos-> navigationItemClick(pos)
//            }
//            vBinding.rvFluorNavigation.adapter = this
//        }
//        vBinding.rvFluorNavigation.layoutManager = GridLayoutManager(getContext(),4)
//    }
//
//    override fun initData() {
//        pagerAdapter = FragmentPagerAdapter<BaseFragment<*,*>>(this).apply {
//            addFragment(CopyFrag.newInstance())
//            addFragment(CopyFrag.newInstance("1"))
//            addFragment(CopyFrag.newInstance("2"))
//            addFragment(CopyFrag.newInstance("3"))
//            vBinding.fluorVp.adapter = this
//        }
//        onNewIntent(intent)
//    }
//
//    private fun navigationItemClick(pos:Int) {
//        navigationAdapter?.let {
//            if (it.selectedPosition == pos){
//                return@let
//            }
//            if (it.listener == null||it.listener!!.onNavigationItemSelected(pos)){
//                it.selectedPosition = pos
//            }
//        }
//    }
//
//    /**
//     * [NavigationAdapter.OnNavigationListener]
//     */
//    override fun onNavigationItemSelected(position: Int): Boolean {
//        return when (position) {
//            in 0..3 -> {
//                vBinding.fluorVp.currentItem = position
//                true
//            }
//            else -> false
//        }
//    }
//
//    private fun switchFragment(fragmentIndex: Int) {
//        if (fragmentIndex == -1) {
//            return
//        }
//        when (fragmentIndex) {
//            in 0..3 -> {
//                vBinding.fluorVp.currentItem = fragmentIndex
//                navigationAdapter?.selectedPosition = fragmentIndex
//            }
//        }
//    }
//    override fun onNewIntent(intent: Intent?) {
//        super.onNewIntent(intent)
//        pagerAdapter?.let {
//            switchFragment(it.getFragmentIndex(getSerializable(INTENT_KEY_IN_FRAGMENT_CLASS)))
//        }
//    }
//
//    override fun onSaveInstanceState(outState: Bundle) {
//        super.onSaveInstanceState(outState)
//        vBinding.fluorVp.let {
//            // 保存当前 Fragment 索引位置
//            outState.putInt(INTENT_KEY_IN_FRAGMENT_INDEX, it.currentItem)
//        }
//    }
//
//    override fun onRestoreInstanceState(savedInstanceState: Bundle) {
//        super.onRestoreInstanceState(savedInstanceState)
//        // 恢复当前 Fragment 索引位置
//        switchFragment(savedInstanceState.getInt(INTENT_KEY_IN_FRAGMENT_INDEX))
//    }
//
//    override fun onDestroy() {
//        super.onDestroy()
//        vBinding.fluorVp.adapter = null
//        vBinding.rvFluorNavigation.adapter = null
//        navigationAdapter?.listener = null
//    }
//
//}